package com.qxzn.app.page.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class MyRecyclerView extends RecyclerView {

    private float mStartX;
    private float mStartY;

    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        switch (e.getAction()) {
            case MotionEvent.ACTION_DOWN:
//                AppUtil.showLog("MyRecyclerView.ACTION_DOWN");
                mStartX = e.getX();
                mStartY = e.getY();
                break;
            case MotionEvent.ACTION_MOVE:
//                AppUtil.showLog("MyRecyclerView.ACTION_MOVE");
                if ((Math.abs(e.getX() - mStartX)) > (Math.abs(e.getY() - mStartY))) {
                    return true;
                } else {
                    return false;
                }
            case MotionEvent.ACTION_UP:
//                AppUtil.showLog("MyRecyclerView.ACTION_UP");
                break;
        }
//        AppUtil.showLog("MyRecyclerView.onInterceptTouchEvent");
        return super.onInterceptTouchEvent(e);
    }

//    @Override
//    public boolean onTouchEvent(MotionEvent e) {
//        switch (e.getAction()) {
//            case MotionEvent.ACTION_DOWN:
//                AppUtil.showLog("onTouchEvent.ACTION_DOWN");
//                break;
//            case MotionEvent.ACTION_MOVE:
//                AppUtil.showLog("onTouchEvent.ACTION_MOVE");
//                break;
//            case MotionEvent.ACTION_UP:
//                AppUtil.showLog("onTouchEvent.ACTION_UP");
//                break;
//        }
//        AppUtil.showLog("onTouchEvent.onTouchEvent");
//        return super.onTouchEvent(e);
//    }
}
